<?php
if (!defined('ROOT_PATH')) die('No direct access.');
function getBLaris(){
	$db = new db();
	$query = "SELECT harga,idBarang,nama,`slug-nama`,terjual FROM `Barang` ORDER BY terjual DESC LIMIT 0,3";
	$ret = $db->query($query);
	return $ret;
}

function getBBaru(){
	$db = new db();
	$query = "SELECT harga,idBarang,nama,`slug-nama` FROM `Barang` ORDER BY tglReg DESC LIMIT 0,3";
	$ret = $db->query($query);
	return $ret;
}

function getTLaris(){
	$db = new db();
	$query = "SELECT SUM(terjual) AS total,idPengguna,idFB,`nama-toko`,`slug_nama-toko` FROM Barang INNER JOIN Pengguna ON idPenjual=idPengguna GROUP BY idPengguna ORDER BY total DESC LIMIT 0,4";
	$ret = $db->query($query);
	return $ret;
}

function getTBaru(){
	$db = new db();
	$query = "SELECT idPengguna,idFB,`nama-toko`,`slug_nama-toko` FROM `Pengguna` WHERE isToko = 1 ORDER BY tgl_reg DESC LIMIT 0,4";
	$ret = $db->query($query);
	return $ret;
}
